import 'package:xws/helpers/as_t.dart';

/// 百度ai识图token响应
class BaiduToken {
  BaiduToken({
    required this.refreshToken,
    required this.expiresIn,
    required this.scope,
    required this.sessionKey,
    required this.accessToken,
    required this.sessionSecret,
    required this.error,
    required this.errorDescription,
  });

  factory BaiduToken.fromJson(Map<String, dynamic> jsonRes) => BaiduToken(
        refreshToken: asT<String>(jsonRes['refresh_token']),
        expiresIn: asT<int>(jsonRes['expires_in']),
        scope: asT<String>(jsonRes['scope']),
        sessionKey: asT<String>(jsonRes['session_key']),
        accessToken: asT<String>(jsonRes['access_token']),
        sessionSecret: asT<String>(jsonRes['session_secret']),
        error: asT<String>(jsonRes['error']),
        errorDescription: asT<String>(jsonRes['error_description']),
      );

  late String refreshToken;
  late int expiresIn;
  late String scope;
  late String sessionKey;
  late String accessToken;
  late String sessionSecret;
  late String error;
  late String errorDescription;
}
